# -*- coding: utf-8 -*-
from flask import Flask
from config import config
from app import db, db2


def create_app(config_name):
    app = Flask('app')
    app.config.from_object(config[config_name])
    config[config_name].init_app(app)
    db.init_app(app)
    db2.init_app(app)
    from .module.common import common
    from .module.api.views import module_api
    from .module.NEP.ALS.views import module_nep_als
    from .module.NEP.PSS.views import module_nep_pss
    from .module.Tiexi.ProductionVolume.views import module_tx_prod_vol
    from .module.Tiexi.BBT.views import module_tx_bbt
    from .module.Dadong.NEX.views import module_dd_nex
    app.register_blueprint(common)
    app.register_blueprint(module_api, url_prefix='/api')
    app.register_blueprint(module_nep_als, url_prefix='/NEP/ALS')
    app.register_blueprint(module_nep_pss, url_prefix='/NEP/PSS')
    app.register_blueprint(module_tx_prod_vol, url_prefix='/Tiexi')
    app.register_blueprint(module_tx_bbt, url_prefix='/Tiexi/BBT')
    app.register_blueprint(module_dd_nex, url_prefix='/Dadong/NEX')
    return app
